'''
Created on May 4, 2011

@author: Chris
'''
import re
class RegExpHandler(object):
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
        
    def splitStringRegExp(self, text, pattern):
        """ 
        split the string based on the pattern and returns a list 
        """
        return re.split(pattern, text)
    
    def replaceRegex(self, text, pattern, replacement):
        """ 
        replaces any matches of the pattern in text with replacement 
        """
        return re.sub(pattern, replacement, text)
    
if __name__ == '__main__': 
            
    regexp = RegExpHandler()
    doc = "Hello, my name is test."
    #print re.sub('H', 'B', doc)
    print regexp.replaceRegex(doc, '[.?]$', '!') 
    
    doc2 = "You are the best. Seriously dog! You're awesome."
    a = regexp.splitStringRegExp(doc2, "([.?!])")
    a.pop()
    print a
    
    

        